home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 039a / netpq203.zip / SHOWDATA.C < prev    next >
Text File  |  1993-03-05  |  7KB  |  308 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. #include "nos.h"
  5. #include "noslib.h"
  6. #include "netpq.h"
  7. #include "proto.h"
  8.  
  9. extern struct serverdef *server;
  10. extern struct localqueuedef *localqueue;
  11.  
  12. extern int currentserver, adaptornum, numberoflogins, currentprinter, found;
  13. extern int queuejobcount, printjobcount;
  14. extern int maxlocalqueuecount, localqueuecount;
  15. extern int monoflag, timeout;
  16.  
  17. char *statusstring [] =
  18.     {
  19.     "FREE",
  20.     "UPDATING",
  21.     "HOLDING",
  22.     "WAITING",
  23.     "DESPOOLING",
  24.     "CANCELLED",
  25.     "FILE ERROR",
  26.     "SPOOL ERROR",
  27.     "* RUSH *"
  28.     };
  29.  
  30. int numberofprinterstrings = 6;
  31. char *printerstring [] =
  32.     {
  33.     "LPT1:",
  34.     "LPT2:",
  35.     "LPT3:",
  36.     "COM1:",
  37.     "COM2:",
  38.     "ALL"
  39.     };
  40.  
  41. char *printerstatusstring [] =
  42.     {
  43.     "Disabled",
  44.     "Single",
  45.     "Enabled"
  46.     };
  47.  
  48.  
  49.  
  50. void reportinfo ()
  51.     {
  52.     //report server name & time
  53.  
  54.     currentserver = 0;
  55.  
  56.     while (currentserver < numberoflogins)
  57.     {
  58.     highlight ();
  59.     cprintf ("%-15s", server [currentserver] .servername);
  60.     nohighlight ();
  61.     cprintf ("%*s%02d/%02d/%04d %02d:%02d:%02d", 42,"",
  62.         server [currentserver] .time.TB_month,
  63.         server [currentserver] .time.TB_day,
  64.         server [currentserver] .time.TB_year,
  65.         server [currentserver] .time.TB_hour,
  66.         server [currentserver] .time.TB_minutes,
  67.         server [currentserver] .time.TB_seconds);
  68.     cprintf ("\r\n");
  69.  
  70.     reportprinterstatus ();
  71.  
  72.     reportprinterjobs ();
  73.  
  74.     currentserver++;
  75.     }
  76.     }
  77.  
  78.  
  79.  
  80. void reportprinterstatus ()
  81.     {
  82.     //    report status of each of the 5 printer ports on the server
  83.  
  84.     currentprinter = 0;
  85.     while (currentprinter < 5)
  86.     {
  87.     if (server [currentserver] .PS_state_value [currentprinter] != 0)
  88.         {
  89.         highlight ();
  90.         cprintf ("%s ", printerstring [currentprinter]);
  91.  
  92.         if (server [currentserver] .PS_state_pause [currentprinter] == 1)
  93.         {
  94.         highlightblink ();
  95.         cprintf ("%-10s", "Paused");
  96.         }
  97.         else
  98.         {
  99.         if (server [currentserver] .PS_index [currentprinter] < 65535)
  100.             {
  101.             if (server [currentserver] .PS_CPS [currentprinter] == 0)
  102.             highlightblink ();
  103.             cprintf ("%4d CPS  ", server [currentserver] .PS_CPS [currentprinter]);
  104.             }
  105.         else
  106.             cprintf ("%-10s", printerstatusstring [server [currentserver] .PS_state_value [currentprinter] ]);
  107.         }
  108.         nohighlight ();
  109.         }
  110.     else
  111.         {
  112.         cprintf ("%s ", printerstring [currentprinter]);
  113.         cprintf ("Disabled  ");
  114.         }
  115.     currentprinter++;
  116.     }
  117.     cprintf ("\r\n");
  118.     }
  119.  
  120.  
  121.  
  122. void reportprinterjobs ()
  123.     {
  124.     //report status of each printer job in the server's queue
  125.  
  126.     int outputjobcount;
  127.     int hours, minutes;
  128.     int month, date, year;
  129.     DWORD percent;
  130.  
  131.     printjobcount = 0;
  132.     outputjobcount = 0;
  133.     found = false;
  134.  
  135.     while (printjobcount < localqueuecount)
  136.     {
  137.     if (localqueue [printjobcount] .server == currentserver)
  138.         {
  139.         if (found == false)
  140.         {
  141.         nohighlight ();
  142.         cprintf ("%-5s %-9s %-9s %-5s %-12s %-8s %11s %8s %3s",
  143.             "SEQ #", "USER NAME", "MACHINE", "TIME", "COMMENT",
  144.             "PRINTER", "STATUS", "SIZE", "PCT");
  145.         cprintf ("\r\n");
  146.         found = true;
  147.         }
  148.  
  149.         choosecolor (localqueue [printjobcount] .qe .QE_status);
  150.         localqueue [printjobcount] .qe .QE_user [9] = '\0';
  151.         localqueue [printjobcount] .qe .QE_machine [9] = '\0';
  152.         localqueue [printjobcount] .qe .QE_comment [12] = '\0';
  153.         localqueue [printjobcount] .qe .QE_destination [8] = '\0';
  154.         hours   =  localqueue [printjobcount] .qe .QE_time / 0x0800;
  155.         minutes = (localqueue [printjobcount] .qe .QE_time & 0x07c0) / 0x0020;
  156.         year    =  localqueue [printjobcount] .qe .QE_date / 0x0200 + 1980;
  157.         month   = (localqueue [printjobcount] .qe .QE_date & 0x01e0) / 0x0020;
  158.         date    =  localqueue [printjobcount] .qe .QE_date & 0x001f;
  159.  
  160.  
  161.         cprintf ("%-5lu", localqueue [printjobcount] .qe .QE_sequence);
  162.         cprintf (" %-9s", localqueue [printjobcount] .qe .QE_user);
  163.         cprintf (" %-9s", localqueue [printjobcount] .qe .QE_machine);
  164.         cprintf (" %02d:%02d", hours, minutes);
  165.  
  166.         if (strlen (localqueue [printjobcount] .qe .QE_comment) > 0)
  167.         cprintf (" %-12s", localqueue [printjobcount] .qe .QE_comment);
  168.         else
  169.         cprintf (" %02d/%02d/%04d  ", month, date, year);
  170.  
  171.         cprintf (" %-8s", localqueue [printjobcount] .qe .QE_destination);
  172.  
  173.         //    If despooling, display number of bytes sent
  174.  
  175.         if ( (localqueue [printjobcount] .qe .QE_status == 4) && (localqueue [printjobcount] .printer != -1) )
  176.         {
  177.         percent = 100 *
  178.             server [currentserver] .PS_output_chars [localqueue [printjobcount] .printer] /
  179.             localqueue [printjobcount] .qe .QE_size;
  180.  
  181.         cprintf (" %8lu of", server [currentserver] .PS_output_chars [localqueue [printjobcount] .printer]);
  182.         cprintf (" %8lu", localqueue [printjobcount] .qe .QE_size);
  183.         cprintf (" %3lu", percent);
  184.         }
  185.         else
  186.         {
  187.         cprintf (" %11s", statusstring [localqueue [printjobcount] .qe .QE_status] );
  188.         cprintf (" %8lu", localqueue [printjobcount] .qe .QE_size);
  189.         cprintf ("   0");
  190.         }
  191.         cprintf ("\r\n");
  192.         outputjobcount++;
  193.         if ( (localqueuecount > (21 - (numberoflogins * 5))) &&
  194.         (outputjobcount > (21 - (numberoflogins * 5)) / numberoflogins))
  195.         {
  196.         errorhighlight ();
  197.         cprintf ("Total of %d files in queue\r\n", server [currentserver] .queue_jobs);
  198.         printjobcount = localqueuecount;
  199.         }
  200.         nohighlight ();
  201.         }
  202.     printjobcount++;
  203.     }
  204.  
  205.     if (found == false)
  206.     {
  207.     cprintf ("No files spooled");
  208.     cprintf ("\r\n");
  209.     }
  210.     cprintf ("\r\n");
  211.     }
  212.  
  213.  
  214. int getextch ()
  215.     {
  216.     //    gets value of extended key press
  217.  
  218.     int c;
  219.     c = getch ();
  220.     if (c == 0)
  221.     {
  222.     c = getch ();
  223.     if (c < 128)
  224.         c += 128;
  225.     }
  226.     return (c);
  227.     }
  228.  
  229.  
  230. void highlight ()
  231.     {
  232.     //    sets colors for active servers, and ports
  233.  
  234.     if (!monoflag)
  235.     textcolor (BROWN);
  236.     highvideo ();
  237.     }
  238.  
  239.  
  240. void nohighlight ()
  241.     {
  242.     //    sets colors for server time & inactive ports
  243.  
  244.     if (!monoflag)
  245.     textcolor (CYAN);
  246.     lowvideo ();
  247.     }
  248.  
  249.  
  250. void highlightblink ()
  251.     {
  252.     //    sets colors for paused and 0 CPS ports
  253.  
  254.     if (!monoflag)
  255.     textcolor (RED + BLINK);
  256.     highvideo ();
  257.     }
  258.  
  259. void errorhighlight ()
  260.     {
  261.     //    sets colors for error messages
  262.  
  263.     if (!monoflag)
  264.     textcolor (RED);
  265.     highvideo ();
  266.     }
  267.  
  268. void choosecolor (int status)
  269.     {
  270.     //    sets colors for queued files status
  271.  
  272.     switch (status)
  273.     {
  274.     case 2:
  275.         nohighlight ();
  276.         if (!monoflag)
  277.         textcolor (RED);
  278.         break;
  279.     case 3:
  280.     case 8:
  281.         nohighlight ();
  282.         if (!monoflag)
  283.         textcolor (GREEN);
  284.         break;
  285.     case 4:
  286.         highlight ();
  287.         break;
  288.     default:
  289.         nohighlight ();
  290.         break;
  291.     }
  292.     }
  293.  
  294.  
  295.  
  296. void message (char *messagetext, int eraseflag)
  297.     {
  298.     //    displays message in center of the first line of the screen
  299.  
  300.     gotoxy ( (40 - (strlen (messagetext) / 2) ), 1);
  301.     errorhighlight ();
  302.     cprintf ("%s", messagetext);
  303.     nohighlight ();
  304.  
  305.     if (eraseflag == true)
  306.     sleep (3);
  307.     }
  308.